package io;

import java.io.*;

/** 对象流是高级流作用是进行对象的序列化和反序列化
 * 本案例演示序列化 */
public class OosDemo  {
    public static void main(String[] args) throws IOException {
    String name = "范传奇";
    int age = 25;
    String gender = "男";
    String[] otherInfo ={"帅","技术好","有钱","是老师"};
    Person person = new Person(name,age,gender,otherInfo);
        FileOutputStream fos = new FileOutputStream("person.obj");//低级流()文件输出流
        ObjectOutputStream oos = new ObjectOutputStream(fos);//高级流 对象输出流
        /**对象输出流在进行序列化时，要求对象必须可序列化接口Serializable
         * 否则调用writeObject时会出现NotSerializableException异常 */
        oos.writeObject(person);//写出对象
        System.out.println("写出完毕");
        oos.close();
    }
}
